home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / jpsrc2.zip / JINCLUDE.H < prev    next >
C/C++ Source or Header  |  1991-12-12  |  4KB  |  103 lines

  1. /*
  2.  * jinclude.h
  3.  *
  4.  * Copyright (C) 1991, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This is the central file that's #include'd by all the JPEG .c files.
  9.  * Its purpose is to provide a single place to fix any problems with
  10.  * including the wrong system include files.
  11.  * You can edit these declarations if you use a system with nonstandard
  12.  * system include files.
  13.  */
  14.  
  15.  
  16. /*
  17.  * Normally the __STDC__ macro can be taken as indicating that the system
  18.  * include files conform to the ANSI C standard.  However, if you are running
  19.  * GCC on a machine with non-ANSI system include files, that is not the case.
  20.  * In that case change the following, or add -DNONANSI_INCLUDES to your CFLAGS.
  21.  */
  22.  
  23. #ifdef __STDC__
  24. #ifndef NONANSI_INCLUDES
  25. #define INCLUDES_ARE_ANSI    /* this is what's tested before including */
  26. #endif
  27. #endif
  28.  
  29. /*
  30.  * <stdio.h> is included to get the FILE typedef and NULL macro.
  31.  * Note that the core portable-JPEG files do not actually do any I/O
  32.  * using the stdio library; only the user interface, error handler,
  33.  * and file reading/writing modules invoke any stdio functions.
  34.  * (Well, we did cheat a bit in jvirtmem.c, but only if MEM_STATS is defined.)
  35.  */
  36.  
  37. #include <stdio.h>
  38.  
  39. /*
  40.  * We need the size_t typedef, which defines the parameter type of malloc().
  41.  * In an ANSI-conforming implementation this is provided by <stdio.h>,
  42.  * but on non-ANSI systems it's more likely to be in <sys/types.h>.
  43.  * On some not-quite-ANSI systems you may find it in <stddef.h>.
  44.  */
  45.  
  46. #ifndef INCLUDES_ARE_ANSI    /* shouldn't need this if ANSI C */
  47. #include <sys/types.h>
  48. #endif
  49. #ifdef __SASC            /* Amiga SAS C provides it in stddef.h. */
  50. #include <stddef.h>
  51. #endif
  52.  
  53. /*
  54.  * In ANSI C, and indeed any rational implementation, size_t is also the
  55.  * type returned by sizeof().  However, it seems there are some irrational
  56.  * implementations out there, in which sizeof() returns an int even though
  57.  * size_t is defined as long or unsigned long.  To ensure consistent results
  58.  * we always use this SIZEOF() macro in place of using sizeof() directly.
  59.  */
  60.  
  61. #undef SIZEOF            /* in case you included X11/xmd.h */
  62. #define SIZEOF(object)    ((size_t) sizeof(object))
  63.  
  64. /*
  65.  * fread() and fwrite() are always invoked through these macros.
  66.  * On some systems you may need to twiddle the argument casts.
  67.  * CAUTION: argument order is different from underlying functions!
  68.  */
  69.  
  70. #define FREAD(file,buf,sizeofbuf)  \
  71.   ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  72. #define FWRITE(file,buf,sizeofbuf)  \
  73.   ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  74.  
  75. /*
  76.  * We need the memcpy() and strcmp() functions, plus memory zeroing.
  77.  * ANSI and System V implementations declare these in <string.h>.
  78.  * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  79.  * NOTE: we assume the size parameters to these functions are of type size_t.
  80.  * Insert casts in these macros if not!
  81.  */
  82.  
  83. #ifdef INCLUDES_ARE_ANSI
  84. #include <string.h>
  85. #define MEMZERO(voidptr,size)    memset((voidptr), 0, (size))
  86. #else /* not ANSI */
  87. #ifdef BSD
  88. #include <strings.h>
  89. #define MEMZERO(voidptr,size)    bzero((voidptr), (size))
  90. #define memcpy(dest,src,size)    bcopy((src), (dest), (size))
  91. #else /* not BSD, assume Sys V or compatible */
  92. #include <string.h>
  93. #define MEMZERO(voidptr,size)    memset((voidptr), 0, (size))
  94. #endif /* BSD */
  95. #endif /* ANSI */
  96.  
  97.  
  98. /* Now include the portable JPEG definition files. */
  99.  
  100. #include "jconfig.h"
  101.  
  102. #include "jpegdata.h"
  103.